<?php
namespace app\common\component\parameters;

class ParametersService {
	public function getParameters() {
		$resultParameters = (new ParametersModel()) -> select();

		if($resultParameters) {
			return [
				'code' => 0,
				'data' => [
					'parameters' => $resultParameters
				]
			];
		}

		return [
			'code' => -1,
			'message' => '参数为空'
		];
	}

	public function update($data, $key) {
		$updateParameters = (new ParametersModel()) -> where('key', $key) -> update($data);

		if($updateParameters) {
			return [
				'code' => 0,
				'message' => '参数修改成功'
			];
		}

		return [
			'code' => -1,
			'message' => '参数修改失败'
		];
	}
}
?>